import axios from "axios";
import store from "@/store";

export const musicAxios = axios.create({
  timeout: 3000,
  headers: {
    authorization: 'bearer token',
  },
})

musicAxios.interceptors.request.use(
  (config) => {
    console.log('music请求拦截器', config);
    return config;
  },
  (error) => {
    Promise.reject(error);
  }
);

musicAxios.interceptors.response.use(
  (response) => {
    console.log('music响应拦截器', response);
    return response.data;
  },
  (error) => {
    Promise.reject(error);
  }
);

export const shopAxios = axios.create({
  timeout: 3000,
  // headers: { authorization: token },
  dataType: 'json',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    authorization: store.getters.token ? store.getters.token : '',
  }
  
});
console.log(store)
shopAxios.interceptors.request.use(
  (config) => {
    // console.log('shop请求拦截器', config);
    return config;
  },
  (error) => {
    Promise.reject(error);
  }
);

shopAxios.interceptors.response.use(
  (response) => {
    // console.log('shop响应拦截器', response);
    return response.data;
  },
  (error) => {
    Promise.reject(error);
  }
);
